package org.needcoke.hs.http;

import java.util.HashMap;
import java.util.Map;

public enum ContentType {

    FORM_URLENCODED("application/x-www-form-urlencoded"),
    MULTIPART("multipart/form-data"),
    JSON("application/json"),
    XML("application/xml"),
    TEXT_PLAIN("text/plain"),
    TEXT_XML("text/xml"),
    TEXT_HTML("text/html"),
    OCTET_STREAM("application/octet-stream");

    private final String value;

    public String getValue() {
        return value;
    }

    ContentType(String value) {
        this.value = value;
    }

    private static final Map<String, ContentType> contentTypeMap;

    static {
        contentTypeMap = new HashMap<>();
        ContentType[] values = ContentType.values();
        for (ContentType ct : values) {
            contentTypeMap.put(ct.value, ct);
        }
    }

    public static ContentType getContentTypeByValue(String value){
        return contentTypeMap.get(value);
    }
}
